package 美团;

import sun.util.locale.provider.DateFormatProviderImpl;

import java.util.Scanner;

/**
 * @Author Weton Li
 * @Date 2021/3/2 20:29
 */
 class 翻转数组 {

    public static void rotato1(int[][] matrix) {

        int n = matrix.length;
        // 转置矩阵
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                int temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }
    }

//    public static void rotato(int[][] matrix) {
//        int n = matrix.length;
//        for (int i = 0; i < (n + 1) / 2; i++) {
//            for (int j = 0; j < n / 2; j++) {
//                int temp = matrix[i][j];
//                // 当前列 = 新的行 当前行+新的列=n-1
//                matrix[i][j] = matrix[i][j];
//                matrix[i][j] = matrix[n - 1 - j][i];
//                matrix[n - 1 - j][i] = matrix[n - 1 - i][n - 1 - j];
//                matrix[n - 1 - i][n - 1 - j] = temp;
//            }
//        }
//    }

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int j = scanner.nextInt();
        int[][] matrix = new int[i][j];
        for (int k = 0; k < i; k++) {
            for (int l = 0; l < j; l++) {
                int input = scanner.nextInt();
                matrix[k][l]=input;
            }
        }
        rotato1(matrix);
        for (int[] line:matrix){
            for (int point:line){
                System.out.print(point+" ");
            }
            System.out.println();
        }
    }
}
